import axios from "axios";
import * as reducerType from './reducerType';
const initState = {
  isAuth: false,
  user: 'messi',
  age: 55,
  gunCount: 0,
  mobile: '',
  name: '',
  isAuth: false
}

const userReducer = (state = initState, action) => {
  switch (action.type) {
    case reducerType.ADD:
      return { ...state, gunCount: ++state.gunCount };
    case reducerType.LESS:
      return { ...state,  gunCount: --state.gunCount };  
    case reducerType.LOGIN:
      console.error('你来到了登录', action)
      return { ...state, isAuth: true, ...action.payload };
    case reducerType.LOGOUT:
      return { ...state, isAuth: false };
    case reducerType.USER_DATA:
      return { ...state, ...action.payload }
    default:
      return state;
  }
}

export default userReducer;